{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
	<h3 class="pb-3">编辑用户信息</h3>
	<table class="layui-table layui-table-form">
		<tr>
			<input type="hidden" name="id" value="{$user.id}">
			<td class="layui-td-gray">用户昵称<font>*</font></td>
			<td>
				<input type="text" name="nickname" placeholder="请输入用户昵称"	autocomplete="off" class="layui-input" value="{$user.nickname}" lay-verify="required" lay-reqText="请输入用户昵称">
			</td>
			<td class="layui-td-gray">状态</td>
			<td>
				<input type="radio" name="status" value="0" title="禁用" {eq name="$user.status" value="0" }checked{/eq}>
				<input type="radio" name="status" value="1" title="正常" {eq name="$user.status" value="1" }checked{/eq}>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">登录手机号码</td>
			<td>
				<input type="text" name="mobile" placeholder="请输入手机"	autocomplete="off" class="layui-input" value="{$user.mobile}">
			</td>
			<td class="layui-td-gray">密码</td>
			<td>
				<input type="text" name="password" placeholder="请输入密码"	autocomplete="off" class="layui-input" value="{$user.password}" >
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">个人vip</td>
			<td>
				<input type="radio" name="is_vip_one" lay-filter="vip_one" value="0" title="否" {eq name="$user.is_vip_one" value="0" }checked{/eq}>
				<input type="radio" name="is_vip_one" lay-filter="vip_one" value="1" title="是" {eq name="$user.is_vip_one" value="1" }checked{/eq}>
			</td>
			<td id="one1" {eq name="$user.is_vip_one" value="0" }style="display:none"{/eq} class="layui-td-gray">到期时间</td>
			<td id="one2" {eq name="$user.is_vip_one" value="0" }style="display:none"{/eq}>
				<input type="text" id="time1" readonly name="vip_end_time_one" autocomplete="off" class="layui-input" value="{$user.vip_end_time_one}" >
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">企业vip</td>
			<td>
				<input type="radio" name="is_vip_two" lay-filter="vip_two" value="0" title="否" {eq name="$user.is_vip_two" value="0" }checked{/eq}>
				<input type="radio" name="is_vip_two" lay-filter="vip_two" value="1" title="是" {eq name="$user.is_vip_two" value="1" }checked{/eq}>
			</td>
			<td id="two1" {eq name="$user.is_vip_two" value="0" }style="display:none"{/eq} class="layui-td-gray">到期时间</td>
			<td id="two2" {eq name="$user.is_vip_two" value="0" }style="display:none"{/eq}>
				<input type="text" id="time2" readonly name="vip_end_time_two" autocomplete="off" class="layui-input" value="{$user.vip_end_time_two}" >
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">个人svip</td>
			<td>
				<input type="radio" name="is_svip_one" lay-filter="vip_three" value="0" title="否" {eq name="$user.is_svip_one" value="0" }checked{/eq}>
				<input type="radio" name="is_svip_one" lay-filter="vip_three" value="1" title="是" {eq name="$user.is_svip_one" value="1" }checked{/eq}>
			</td>
			<td id="three1" {eq name="$user.is_svip_one" value="0" }style="display:none"{/eq} class="layui-td-gray">到期时间</td>
			<td id="three2" {eq name="$user.is_svip_one" value="0" }style="display:none"{/eq}>
				<input type="text" id="time3" readonly name="svip_end_time_one" autocomplete="off" class="layui-input" value="{$user.svip_end_time_one}" >
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">企业svip</td>
			<td>
				<input type="radio" name="is_svip_two" lay-filter="vip_four" value="0" title="否" {eq name="$user.is_svip_two" value="0" }checked{/eq}>
				<input type="radio" name="is_svip_two" lay-filter="vip_four" value="1" title="是" {eq name="$user.is_svip_two" value="1" }checked{/eq}>
			</td>
			<td id="four1" {eq name="$user.is_svip_two" value="0" }style="display:none"{/eq} class="layui-td-gray">到期时间</td>
			<td id="four2" {eq name="$user.is_svip_two" value="0" }style="display:none"{/eq}>
				<input type="text" id="time4" readonly name="svip_end_time_two" autocomplete="off" class="layui-input" value="{$user.svip_end_time_two}" >
			</td>
		</tr>
	</table>

	<div class="py-3">
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool'];
	function gouguInit() {
		var tool = layui.tool, laydate = layui.laydate, form = layui.form;
		form.on('radio(vip_one)', function (data) {
			var value = data.value;   //  当前选中的value值
			if (value == '0') {
				$('#one1').hide();
				$('#one2').hide();
			} else {
				$('#one1').show();
				$('#one2').show();
			}
		});
		form.on('radio(vip_two)', function (data) {
			var value = data.value;   //  当前选中的value值
			if (value == '0') {
				$('#two1').hide();
				$('#two2').hide();
			} else {
				$('#two1').show();
				$('#two2').show();
			}
		});
		form.on('radio(vip_three)', function (data) {
			var value = data.value;   //  当前选中的value值
			if (value == '0') {
				$('#three1').hide();
				$('#three2').hide();
			} else {
				$('#three1').show();
				$('#three2').show();
			}
		});
		form.on('radio(vip_four)', function (data) {
			var value = data.value;   //  当前选中的value值
			if (value == '0') {
				$('#four1').hide();
				$('#four2').hide();
			} else {
				$('#four1').show();
				$('#four2').show();
			}
		});
		laydate.render({
			elem: '#time1',
			type: 'date',
			min:0
		});
		laydate.render({
			elem: '#time2',
			type: 'date',
			min:0
		});
		laydate.render({
			elem: '#time3',
			type: 'date',
			min:0
		});
		laydate.render({
			elem: '#time4',
			type: 'date',
			min:0
		});
		//监听提交
		form.on('submit(webform)', function (data) {
			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					parent.layui.tool.close(1000);					
				}
			}
			tool.post("/admin/user/edit", data.field, callback);
			return false;
		});
	}
</script>
{/block}
<!-- /脚本 -->